Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New test for validation with dots #759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m1k1o
Copy link

@m1k1o m1k1o commented Feb 11, 2025

Since in v0.62.0 was introduced a new validation, that was advised as a breaking change, it indeed it was transparent breaking change for me.

I am using OTEL that is exporting metrics via prometheus. They contain dots in the name e.g. module.submodule.metric_name. Up until this change, they were changed to module_submodule_metric_name and everything worked properly.

Since this breaking change, they do contain the dot. However, only when requesting metrics with escaping=allow-utf-8 what is prometheus doing by default.

It was tricky to find the root of this behavior change, since curl 127.0.0.1:9000/metrics yields correct results, but curl -H 'Accept: text/plain;escaping=allow-utf-8' 127.0.0.1:9000/metrics adds dots to the name.

I don't know if this change was intended, if I should change my metrics everywhere to include the dot or not. In any case, I just added tests to validate with dots so the expected behavior is defined in tests.

Signed-off-by: Miroslav Šedivý <[email protected]>
@m1k1o m1k1o force-pushed the feature/test-validation-with-dots branch from 86ba20d to f220878 Compare February 11, 2025 17:57
@m1k1o m1k1o changed the title Test validation with dots New test for validation with dots Feb 11, 2025
@beorn7 beorn7 requested a review from ywwg February 11, 2025 20:15
@ywwg
Copy link
Member

ywwg commented Feb 12, 2025

yields correct results, but curl -H 'Accept: text/plain;escaping=allow-utf-8' 127.0.0.1:9000/metrics adds dots to the name

I would reword this because the use of "correct" and "adds dots" are misleading: curling without setting the Accept headers to indicate that your endpoint supports UTF-8 names yields results that match the behavior you expected because the library is escaping the names as it did in previous versions. However with the Accept header that indicates support for utf-8, the library does not escape the names and instead allows them through as-is. Dots are not being "added" anywhere, they are no longer being escaped to underscores.

This behavior is already tested in numerous places but if it helps to have this one as well that's ok by me.

@ywwg
Copy link
Member

ywwg commented Feb 12, 2025

for your situation, you probably want to set the metric_name_validation_scheme config option to "legacy" which will tell prometheus to escape the names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants